<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>emp-toolkit: /Users/wangxiao/git/emp-toolkit/emp-tool/utils/utils_ec.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo-full-doxygen.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">emp-toolkit
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('utils__ec_8hpp_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">utils_ec.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="utils__ec_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"><a class="line" href="utils__ec_8hpp.html#a8ed7eb78162c7568c1884dffe014c37e">    1</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="utils__ec_8hpp.html#a8ed7eb78162c7568c1884dffe014c37e">bn_to_block</a>(<a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a> * b, <span class="keyword">const</span> bn_t bn) {</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;    bn_write_bin((uint8_t*)b, <span class="keyword">sizeof</span>(<a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a>), bn);</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;}</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;</div><div class="line"><a name="l00005"></a><span class="lineno"><a class="line" href="utils__ec_8hpp.html#a40171df044fc78651ebe5f1aa9e9fa60">    5</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="utils__ec_8hpp.html#a40171df044fc78651ebe5f1aa9e9fa60">block_to_bn</a>(bn_t bn, <span class="keyword">const</span> <a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a> * b) {</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;    bn_read_bin(bn, (<span class="keyword">const</span> uint8_t*)b, <span class="keyword">sizeof</span>(<a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a>));</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;}</div><div class="line"><a name="l00008"></a><span class="lineno"><a class="line" href="utils__ec_8hpp.html#a782fdb3f06e7f49116d014d4a583b19f">    8</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="utils__ec_8hpp.html#a782fdb3f06e7f49116d014d4a583b19f">initialize_relic</a>() {</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;    <span class="keywordflow">if</span>(initialized) <span class="keywordflow">return</span>;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;    initialized = <span class="keyword">true</span>;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;    <span class="keywordflow">if</span> (core_init() != STS_OK) {</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;        core_clean();</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;        exit(1);</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    }</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;    eb_param_set(EBACS_B251);</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;}</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment">//TODO: fix the following.</span></div><div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="utils__ec_8hpp.html#ae5e3f2827ebda785cd770866307cc26d">   20</a></span>&#160;<span class="keyword">inline</span> <a class="code" href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a> <a class="code" href="utils__ec_8hpp.html#ae5e3f2827ebda785cd770866307cc26d">KDF</a>(eb_t in) {</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    uint8_t tmp[100];</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="keywordtype">int</span> eb_size= eb_size_bin(in, <a class="code" href="utils__ec_8h.html#af693362576a030d027a217a609106008">ECC_PACK</a>);</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    eb_write_bin(tmp, eb_size, in, <a class="code" href="utils__ec_8h.html#af693362576a030d027a217a609106008">ECC_PACK</a>);</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_hash.html#a0b3eafe3161e79b29a1501890bc3bbc0">Hash::hash_for_block</a>(&amp;tmp[0], eb_size);</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;}</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="ttc" id="utils__ec_8hpp_html_a40171df044fc78651ebe5f1aa9e9fa60"><div class="ttname"><a href="utils__ec_8hpp.html#a40171df044fc78651ebe5f1aa9e9fa60">block_to_bn</a></div><div class="ttdeci">void block_to_bn(bn_t bn, const block *b)</div><div class="ttdef"><b>Definition:</b> utils_ec.hpp:5</div></div>
<div class="ttc" id="garble_2block_8h_html_a65abbf31b0a30290189cdb5059b5f785"><div class="ttname"><a href="garble_2block_8h.html#a65abbf31b0a30290189cdb5059b5f785">block</a></div><div class="ttdeci">__m128i block</div><div class="ttdef"><b>Definition:</b> block.h:8</div></div>
<div class="ttc" id="utils__ec_8hpp_html_a8ed7eb78162c7568c1884dffe014c37e"><div class="ttname"><a href="utils__ec_8hpp.html#a8ed7eb78162c7568c1884dffe014c37e">bn_to_block</a></div><div class="ttdeci">void bn_to_block(block *b, const bn_t bn)</div><div class="ttdef"><b>Definition:</b> utils_ec.hpp:1</div></div>
<div class="ttc" id="utils__ec_8h_html_af693362576a030d027a217a609106008"><div class="ttname"><a href="utils__ec_8h.html#af693362576a030d027a217a609106008">ECC_PACK</a></div><div class="ttdeci">#define ECC_PACK</div><div class="ttdef"><b>Definition:</b> utils_ec.h:9</div></div>
<div class="ttc" id="utils__ec_8hpp_html_a782fdb3f06e7f49116d014d4a583b19f"><div class="ttname"><a href="utils__ec_8hpp.html#a782fdb3f06e7f49116d014d4a583b19f">initialize_relic</a></div><div class="ttdeci">void initialize_relic()</div><div class="ttdef"><b>Definition:</b> utils_ec.hpp:8</div></div>
<div class="ttc" id="utils__ec_8hpp_html_ae5e3f2827ebda785cd770866307cc26d"><div class="ttname"><a href="utils__ec_8hpp.html#ae5e3f2827ebda785cd770866307cc26d">KDF</a></div><div class="ttdeci">block KDF(eb_t in)</div><div class="ttdef"><b>Definition:</b> utils_ec.hpp:20</div></div>
<div class="ttc" id="class_hash_html_a0b3eafe3161e79b29a1501890bc3bbc0"><div class="ttname"><a href="class_hash.html#a0b3eafe3161e79b29a1501890bc3bbc0">Hash::hash_for_block</a></div><div class="ttdeci">static block hash_for_block(const void *data, int nbyte)</div><div class="ttdef"><b>Definition:</b> hash.h:52</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_eec959d81771dc8b1a750b834e1341eb.html">emp-tool</a></li><li class="navelem"><a class="el" href="dir_363cbed62d1567d90b8cbb6bda69428f.html">utils</a></li><li class="navelem"><a class="el" href="utils__ec_8hpp.html">utils_ec.hpp</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.12 </li>
  </ul>
</div>
</body>
</html>
